import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../Callback/Callback.dart';

CmdTypeCallback? callback;

class LogDropdownView extends StatefulWidget {

  LogDropdownView(CmdTypeCallback c, {super.key}){
    callback = c;
  }

  @override
  _LogDropdownView createState() => _LogDropdownView();
}

class _LogDropdownView extends State<LogDropdownView> {
  String selectedValue = 'V';

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        DropdownButton<String>(
          value: selectedValue,
          items: const [
            DropdownMenuItem<String>(
              value: 'E',
              child: Text('Error'),
            ),
            DropdownMenuItem<String>(
              value: 'D',
              child: Text('debug'),
            ),
            DropdownMenuItem<String>(
              value: 'I',
              child: Text('info'),
            ),
            DropdownMenuItem<String>(
              value: 'V',
              child: Text('verbose'),
            ),
            DropdownMenuItem<String>(
              value: 'W',
              child: Text('warn'),
            ),
          ],
          onChanged: (value) {
            setState(() {
              selectedValue = value!;
              callback?.call(selectedValue);
            });
          },
        ),
      ],
    );
  }
}
